package cn.kgc.controller;

import cn.kgc.entity.CandFollowHrMo;
import cn.kgc.grace.result.GraceJSONResult;
import cn.kgc.service.CandFollowHrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author YC
 */
@RestController
@RequestMapping("/follow")
@Api(tags = "关注管理模块")
public class FollowController {

    @Resource
    private CandFollowHrService candFollowHrService;

    @PostMapping("/addCandFollowHr")
    @ApiOperation(value = "求职者关注HR")
    public GraceJSONResult addCandFollowHr(@RequestBody CandFollowHrMo candFollowHrMo) {
        return GraceJSONResult.ok(candFollowHrService.addCandFollowHr(candFollowHrMo));
    }

    @PostMapping("/deleteCandFollowHr")
    @ApiOperation(value = "求职者取消关注HR")
    public GraceJSONResult deleteCandFollowHr(String candUserId, String hrId) {
        candFollowHrService.deleteCandFollowHr(candUserId, hrId);
        return GraceJSONResult.ok();
    }

    @PostMapping("/pageFollow")
    @ApiOperation(value = "分页查询求职者关注HR的信息")
    public GraceJSONResult page(String candUserId, int pageIndex, int pageSize) {
        return GraceJSONResult.ok(candFollowHrService.page(candUserId, pageIndex, pageSize));
    }

    @PostMapping("/hasFollowedHr")
    @ApiOperation(value = "求职者是否已经关注HR")
    public GraceJSONResult hasFollowedHr(String candUserId, String hrId) {
        return GraceJSONResult.ok(candFollowHrService.hasFollowedHr(candUserId, hrId));
    }

}